package verification.view;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

import verification.check.Check;
import verification.check.imp.CheckImp;
import verification.init.InitBirthday;
import verification.init.InitId;
import verification.init.InitName;
import verification.pack.Pack;
import verification.printformat.PrintFormat;



public class View {
	public void view() {
		Scanner scanner;
		Check check = new CheckImp();
		Pack pack = new Pack();
		System.out.println("Id or Birthday !! Input 'id' or 'name' !!");
	    Scanner scanner1 = new Scanner(System.in);
	    String s1 = scanner1.next();
		try {
			scanner = new Scanner(new File("data.txt"));
			while (scanner.hasNext()){
				String string= scanner.nextLine();
				String[] cu= new String[5];
				cu = check.check(string);
				if(cu==null)continue;
				else{
					if(s1.equals("id")){
						new InitId(pack.pack(cu));
					}else if (s1.equals("birthday")) {
						new InitBirthday(pack.pack(cu));
					}else {
						System.out.println("Input error!!");
					}
				}
			}
			if(s1.equals("id")){
				PrintFormat.printFormat(InitId.treeSet1);
				PrintFormat.printCustomerXml(InitId.treeSet1);
			}else if (s1.equals("birthday")) {
				PrintFormat.printCustomerXml(InitBirthday.treeSet3);
				PrintFormat.printFormat(InitBirthday.treeSet3);
			}else {
				System.out.println("Input error!!");
			}
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
